package com.nbjtjc.safe.mapper.edu;

import java.util.Collection;
import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.nbjtjc.safe.model.edu.EduDailyParticipant;
import com.nbjtjc.safe.model.edu.EduDailyRecord;
import com.nbjtjc.safe.model.edu.EduDailyUserEvaluate;
import com.nbjtjc.util.MyMapper;
@Mapper
public interface EduDailyUserEvaluateMapper extends MyMapper<EduDailyUserEvaluate> {
	List<EduDailyUserEvaluate> search(@Param("edue")EduDailyUserEvaluate eduDailyUserEvaluate);
	
	@Select("select * from edu_daily_user_evaluate where cancel != 1 and edu_daily_info_id = #{infoId}")
	List<EduDailyUserEvaluate> findByInfoId(@Param("infoId") int infoId);
	
	@Insert("INSERT INTO edu_daily_user_evaluate(edu_daily_info_id,user_id) (SELECT #{edr.infoId} AS edu_daily_info_id,user_id FROM edu_daily_participant WHERE edu_daily_info_id = #{edr.infoId} AND participate = 1)")
	int createUserEvaluateByRecord(@Param("edr") EduDailyRecord eduDailyRecord);

	@Update("update edu_daily_user_evaluate set cancel = 1 where edu_daily_info_id = #{infoId}")
	int cancelByInfoId(@Param("infoId") int infoId);
	
	//查询已评价人员
	@Select("select user_id from edu_daily_user_evaluate where cancel = 0 and  edu_daily_info_id = #{infoId} and evaluate is not null")
	List<Integer> findEvalUserByInfoId(@Param("infoId") Integer infoId);

}